<?php
/**
 * Created by JetBrains PhpStorm.
 * User: porterzhang
 * Date: 13-3-5 下午4:44
 * To change this template use File | Settings | File Templates.
 */
if (!defined('IN_MOBILE_API')) {
    exit('Access Denied');
}
include_once 'forum.php';
class cloud_api {
    function common() { }

    function output() {
        $variable = array();
        //判断是否缺少参数
        if (empty($_GET['id']) ) {
            $variable = array(
                'code' => 1001,
                'messagestr' => lang('plugin/cloud', '1001'),
            );
            cloud_core::result(cloud_core::variable($variable));
        }
        $app_function=  C::t('#cloud#cloud_app_function')->fetch_app_function_info($_GET['id']);
        if(empty($app_function)){
            $variable = array(
                'code' => 22001,
                'messagestr' => lang('plugin/cloud', '22001'),
            );
            cloud_core::result(cloud_core::variable($variable));
        }

        $ret=C::t('#cloud#cloud_app_function')->delete_by_function($_GET['id']);
		 
        if(empty($ret)){
            $variable = array(
                'code' => 22003,
                'messagestr' => lang('plugin/cloud', '22003'),
            );
            cloud_core::result(cloud_core::variable($variable));
        }

        //查询出地区id
        $area_array = C::t('#cloud#cloud_app_district')->fetch_status_by_app($app_function['caid']);
        //查询出角色权限表中，功能id和功能父id和地区id
        foreach($area_array as $key=>$value){
            C::t('#cloud#cloud_role_purview')->role_purview_delete_function($app_function['fid'],$value['cadid']);
        }

        //正常返回
        $variable = array(
            'messagestr' => lang('plugin/cloud', '22002'),
        );
        cloud_core::result(cloud_core::variable($variable));
    }
}

?>

